﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.PlanningManagement;
using Digitalmes.Model.ProductManagement;

namespace Digitalmes.Model.PlanningManagement
{
    /// <summary>
    /// ProductionOrder
    /// </summary>
	[Table("ProductionOrder")]

    [Display(Name = "_Model.ProductionOrder")]
    public class ProductionOrder : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._ProductionOrder._ProductId")]
        [Comment("产品")]
        public long? ProductId { get; set; }

        public Product Product { get; set; }    

        [Display(Name = "_Model._ProductionOrder._ProductName")]
        [Comment("产品名称")]
        public string ProductName { get; set; }
        [Display(Name = "_Model._ProductionOrder._Wo")]
        [Comment("工单号")]
     
        public string Wo { get; set; }
        [Display(Name = "_Model._ProductionOrder._OnlineQty")]
        [Comment("上线数量")]
        [Precision(18, 2)]
        
        public decimal OnlineQty { get; set; } = 0;
        [Display(Name = "_Model._ProductionOrder._QualifiedQty")]
        [Comment("合格数量")]
        [Precision(18, 2)]
        public decimal QualifiedQty { get; set; } = 0;
        [Display(Name = "_Model._ProductionOrder._PlanStartTime")]
        [Comment("计划开始时间")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public DateTime? PlanStartTime { get; set; }
        [Display(Name = "_Model._ProductionOrder._PlanEndTime")]
        [Comment("计划结束时间")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public DateTime? PlanEndTime { get; set; }
        [Display(Name = "_Model._ProductionOrder._ActualStartTime")]
        [Comment("实际开始时间")]
        public DateTime? ActualStartTime { get; set; }
        [Display(Name = "_Model._ProductionOrder._ActualEndTime")]
        [Comment("实际完工时间")]
        public DateTime? ActualEndTime { get; set; }
        [Display(Name = "_Model._ProductionOrder._Sort")]
        [Comment("排序")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? Sort { get; set; }
        [Display(Name = "_Model._ProductionOrder._ProductCode")]
        [Comment("产品名称")]
        public string ProductCode { get; set; }
        [Display(Name = "_Model._ProductionOrder._OrderStatus")]
        [Comment("订单状态")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public WoStatusEnum OrderStatus { get; set; }
        [Display(Name = "_Model._ProductionOrder._OrderSource")]
        [Comment("订单来源")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public WoSourceEnum OrderSource { get; set; }
        [Display(Name = "_Model._ProductionOrder._Plan")]
        [Comment("关联计划")]
        public ProductionPlanning Plan { get; set; }
        [Display(Name = "_Model._ProductionOrder._Plan")]
        [Comment("关联计划")]
        public long? PlanId { get; set; }
        [Display(Name = "_Model._ProductionOrder._PlanQty")]
        [Comment("计划数量")]
        [Precision(18,2)]
        
        public decimal PlanQty { get; set; }
        [Display(Name = "_Model._ProductionOrder._CompletedQty")]
        [Comment("完工数量")]
        [Precision(18, 2)]
       
        public decimal CompletedQty { get; set; } = 0;
        [Display(Name = "_Model._ProductionOrder._UnqualifiedQty")]
        [Comment("不合格数量")]
        [Precision(18, 2)]
       
        public decimal UnqualifiedQty { get; set; } = 0;
        [Display(Name = "_Model._ProductionOrder._ScrapQty")]
        [Comment("报废数量")]
        [Precision(18, 2)]
        
        public decimal ScrapQty { get; set; } = 0;
        [Key]
        [Display(Name = "_Model._ProductionOrder._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._ProductionTask._ProdOrder")]
        [InverseProperty("ProdOrder")]
        public List<ProductionTask> ProductionTask_ProdOrder { get; set; }
        [Display(Name = "_Model._ProductionOrder._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
